package com.chcit.share.admin.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chcit.share.admin.core.page.MybatisPageHelper;
import com.chcit.share.admin.core.page.PageRequest;
import com.chcit.share.admin.core.page.PageResult;

import com.chcit.share.admin.model.SysOrg;
import com.chcit.share.admin.dao.SysOrgMapper;
import com.chcit.share.admin.service.SysOrgService;

/**
 * ---------------------------
 * 机构管理 (SysOrgServiceImpl)         
 * ---------------------------
 * 作者：  share-generator
 * 时间：  2019-04-05 01:48:05
 * 说明：  我是由代码生成器生生成的
 * ---------------------------
 */
@Service
public class SysOrgServiceImpl implements SysOrgService {

	@Autowired
	private SysOrgMapper sysOrgMapper;

	@Override
	public int save(SysOrg record) {
		if(record.getId() == null || record.getId() == 0) {
			return sysOrgMapper.add(record);
		}
		return sysOrgMapper.update(record);
	}

	@Override
	public int delete(SysOrg record) {
		return sysOrgMapper.delete(record.getId());
	}

	@Override
	public int delete(List<SysOrg> records) {
		for(SysOrg record:records) {
			delete(record);
		}
		return 1;
	}

	@Override
	public SysOrg findById(Long id) {
		return sysOrgMapper.findById(id);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest) {
		return MybatisPageHelper.findPage(pageRequest, sysOrgMapper);
	}
	
}
